All Questions
376 questions
0votes
0answers
65views
SGID in File Permissions
the following are two scenarios to let you know how i understand the problem and the SGID: Scenario 1: user A is part of the group G. group G has full privileges to 2 files-its the group owner of ...
0votes
1answer
419views
Rsync throwing errors but files appear to be fine
I am doing a massive 200TB transfer with rsync. I used a shell script I found off the internet to spawn a few processes but here is the relevant rsync command itself: rsync --recursive \ ...
1vote
2answers
139views
find files that start with a 6 digit number and matches number from the list
I have a big number of files around 185000, 99% of then start with a 6 digit number follow by underscore and other random symbols and random extensions 312095_ck_image-24-10-20-11-29-1.jpeg ...
0votes
1answer
107views
Is there a command that makes another command "in-place"?
I find myself trying to "edit" a file in-place quite a lot in my shell. Say, I want to remove all lines in words.txt that contain the letter e. Then, I would execute: $ grep -v e words.txt &...
0votes
1answer
65views
How to copy a directory structure and rename a subdirectory in the destination
Given this directory structure $ lsd --tree ...
1vote
1answer
199views
How to trace file descriptor duplication?
I am learning to use redirection. the typical operation is like below: command > file 2>&1 Refer to APUE 3.10 and 3.12, I think the critical syscall sequence is like below: open(...
-3votes
1answer
823views
Im trying to run a shell script but I keep getting If: expression syntax. How to I get rid of it
Good afternoon, I'm trying to run my code for assignment 4 but I keep getting an expression syntax error, can you tell me why? #!/bin/sh if [ "$#" -ne 1 ] then echo "Usage: ...
0votes
4answers
2kviews
Shell script to list all files in a folder on a single line
I have this folder structure: /Brand/ProductCode01 /Brand/ProductCode02 Each ProductCode## folder contains many JPG files, like image01.jpg, image02.jpg and so on I need to create a file that contains ...
-1votes
2answers
136views
Why can I not use find + awk to find the largest file in the filesystem?
Why does this not work? find / -ls 2>/dev/null | awk '$7 > max {max = $7}; END {print max}' This does work: find / -printf "%s\n" 2>/dev/null | sort -nr |head -n1 In the first one, $...
-2votes
1answer
87views
Is the concept of file permission only applicable when access is via shell?
So in Linux we have a concept of file permission. There are three classes: user, group, and others, and there are three types of permissions: read, write, and execute. Now consider this. You are on a ...
0votes
2answers
123views
Delete files with similar names
I have been away from scripting for years, so I was wondering if someone can help in the below. I am migrating from Google Photos to Amazon Photos (about 40k photos). Here is an example of what I ...
1vote
1answer
602views
Why I do get text/plain and text/x-java for two different js files?
I use /usr/bin/file -i file_path to get information about my files. I have a simple website project, in which I have a couple of js files. When I use /usr/bin/file -i file_name.js for some of them, I ...
3votes
1answer
2kviews
How does deletion work with write-protected regular files?
I want to clarify a few things I noticed regarding the file handling in linux (Ubuntu basically but I think this is applicable to every distribution). I noticed that when files are created by root in ...
1vote
1answer
110views
Bash: How to read the script when sourcing it
When bash is executing a script, ls -la /proc/<pid of bash>/fd shows "255 -> /path/to/script". I think that bash reads the script via file discriptor 255, and executes the commands ...
0votes
1answer
112views
Inserting and updating a block of code at the end of a file
So I have a file which looks like the following #ifndef CONFIG_DHCP_H #define CONFIG_DHCP_H FILE_LICENCE(GPL2_OR_LATER_OR_UBDL); #include <config/defaults.h> #define ...